def sequentialSearch(alist, item):
    '''
    顺序搜索: 从头开始依次与查找值进行比较, 找到就返回True;
        如果比较到最后也没有找到, 就返回False
    
    >>> sequentialSearch([1, 2, 32, 8, 17, 19, 42, 13, 0], 99)
    False
    >>> sequentialSearch([1, 2, 32, 8, 17, 19, 42, 13, 0], 13)
    True
    '''
    pos = 0
    found = False

    while pos < len(alist) and not found:
        if alist[pos] == item:
            found = True
        else:
            pos += 1

    return found

def orderedSequetialSearch(alist, item):
    '''
    递增列表搜索: 当遇到一个比item大的元素, 就可以停止搜索
    >>> orderedSequetialSearch([1,3,4,7, 11], 11)
    True
    >>> orderedSequetialSearch([1,3,4,7, 11], 22)
    False
    '''
    pos = 0
    found = False
    while pos < len(alist) and not found:
        if alist[pos] == item:
            found = True
        elif alist[pos] > item:
            break 
        else:
            pos += 1
    return found

def binarySearch(alist, item):
    '''
    二分查找: alist为递增有序列表
    >>> binarySearch([1,3,4,7,11], 22)
    False
    >>> binarySearch([1,3,4,7,11], 11)
    True
    '''
    low = 0
    high = len(alist)
    found = False
    while low < high and not found:
        mid = (low+high)//2
        if alist[mid] == item:
            found = True  
        elif alist[mid] < item:
            low = mid + 1
        else:
            high = mid -1
    return found

if __name__ == '__main__':
    import doctest
    doctest.testmod(verbose=True)